An image file is similar to a zip file to some extent. The image file may include a set of files into a single file according to a certain format, which may be used for a test version of operation system, game, etc. One important characteristic of the image file is that it may be recognized by a specific software and may be directly burned to a disc. The image file may be extended such that there may be more information included in the image file including a system file, a boot file, partition information, etc. Thus, the image file may include all information of a partition or even a hard disk.
Virtual hard disk (VHD) is an image file format of a virtual hard disk. A file with VHD format may be used as the virtual hard disk to format and store data of a virtual machine.
There may be three types of VHD files including a fixed hard disk image file, a dynamic hard disk image file, and a differencing hard disk image file. The size of the fixed hard disk image file is fixed when it is created. The operations for the fixed hard disk image file, such as formatting the file system, writing data, or deleting data, may not change the size of the fixed hard disk image file. The sizes of the dynamic hard disk image file and the differencing hard disk image file may be increased when data is written therein. However, the sizes of the dynamic hard disk image file and the differencing hard disk image file is not reduced when data is deleted therein.
For example, when the dynamic hard disk image file is created with 2 GB of storage space, its initial size may be only be tens of KB. With data written into the dynamic hard disk image file, its size may increase to approximately 2 GB. However, deleting data in the dynamic hard disk image file does not reduce its size.
Based on such characteristics, once data is written into the dynamic hard disk image file or the differencing hard disk image file, its file size is increased. Even if the data is later deleted, the file size does not shrink. Thus, such deleted data still occupies the storage spaces of the VHD, thereby wasting storage spaces.